package org.springblade.modules.admin.controller.suger;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.core.tenant.annotation.TenantIgnore;
import org.springblade.core.tool.api.R;
import org.springblade.modules.admin.entity.Building;
import org.springblade.modules.admin.service.BuildingService;
import org.springblade.modules.admin.service.IMaintainPlanContentService;
import org.springblade.modules.admin.service.suger.EstateSugarService;
import org.springblade.modules.admin.vo.CheckStatisticsTrendVO;
import org.springblade.modules.admin.vo.SugarCheckPlanHalfYearVO;
import org.springblade.modules.admin.vo.sugar.estate.BuildingDetailVo;
import org.springblade.modules.admin.vo.sugar.estate.BuildingStatisticVo;
import org.springblade.modules.admin.vo.sugar.estate.TlwElevatorDetail;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * @author zcc
 * @version 1.0
 * @date 2022/12/22 8:59
 */
@RestController
@AllArgsConstructor
@RequestMapping("/admin/estate/sugar")
@Api(value = "物业数据大屏", tags = "物业数据大屏")
public class EstateSugarController {

	private final BuildingService buildingService;
	private final EstateSugarService sugarService;


	@GetMapping("getBuildingStatisticInfo")
	@ApiOperation("获取项目卡片信息")
	public R<BuildingStatisticVo> getBuildingStatisticInfo() {

		return R.data(sugarService.getBuildingStatisticInfo());
	}


	@GetMapping("building/list")
	@ApiOperation("获取所有的项目信息")
	public R<List<Building>> getBuildList() {
		Building building = new Building();
		building.setTenantId(AuthUtil.getTenantId());
		return R.data(buildingService.getListByBuilding(building));
	}


	@GetMapping("building/detail")
	@ApiOperation("获取项目明细信息")
	public R<BuildingDetailVo> getBuildingDetail(Long buildingId) {
		return R.data(sugarService.getBuildingDetail(buildingId));
	}


	@GetMapping("getTlwElevatorDetail")
	@ApiOperation("获取电梯卡片信息")
	public R<TlwElevatorDetail> getTlwElevatorDetail() {
		return R.data(sugarService.getTlwElevatorDetail());
	}

	/**
	 * @Author lsay
	 * @Description {
	 *   物业端大屏保养 今日保养
	 * }
	 * @Date 15:39 2022/12/23
	 * @Param
	 * @return
	 **/
	@TenantIgnore
	@GetMapping("/check/plan/statistics/today/status")
	public R<List<Map<String,Object>>> estateSugarTodayStatus(){
		return R.data(sugarService.estateSugarTodayStatus(AuthUtil.getTenantId()));
	}

	/**
	 * @Author lsay
	 * @Description {
	 *   物业端大屏保养 保养完成情况
	 * }
	 * @Date 15:39 2022/12/23
	 * @Param
	 * @return
	 **/
	@TenantIgnore
	@GetMapping("/check/plan/statistics/status")
	public R<List<CheckStatisticsTrendVO>> estateSugarCheckPlanStatus(Integer type,String startDate,String endDate){
		return R.data(sugarService.estateSugarCheckPlanStatus(type,startDate,endDate));
	}

	/**
	 * @Author lsay
	 * @Description {
	 *   物业端大屏保养 项目电梯保养统计TOP10
	 * }
	 * @Date 15:39 2022/12/23
	 * @Param
	 * @return
	 **/
	@TenantIgnore
	@GetMapping("/check/plan/statistics/top")
	public R<List<Map<String,Object>>> estateSugarCheckPlanTop(){
		return R.data(sugarService.estateSugarCheckPlanTop(AuthUtil.getTenantId()));
	}

}
